<%@ page language="java" import="mymail.*,java.util.*, java.io.*,javax.mail.*,javax.mail.Part,java.text.DateFormat,javax.mail.internet.*, javax.mail.event.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>OUR| Mailbox</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

</head>

<body >
<%
				String username="";
				String password="";
				username=request.getParameter("username");
				password=request.getParameter("password");
				%>
    <div >

      <div   class="gray-bg">
        <div class="row border-bottom">
        <nav class="navbar navbar-static-top white-bg" role="navigation" style="margin-bottom: 0">
       <div class="navbar-header">
            <span class="navbar-minimalize minimalize-styl-2 btn btn-primary" style=" margin-left:38px" >our邮箱 </span>
         </div>	
		
                   <ul class="nav navbar-top-links navbar-right">
              <li> <span class="m-r-sm text-muted welcome-message" style="font-size: 28px;font-family:jokerman;color: #8FB586"><strong>hello,welcome to our emailbox!</strong>&nbsp;&nbsp;&nbsp;<%=username%>@arman.com</span> </li>
              <li>
                    <a href="index.jsp">
                        <i></i> 退出	
                    </a>
                </li>
            </ul>

        </nav>
        </div>

        <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-lg-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content mailbox-content">
                        <div class="file-manager">
                             <ul class="folder-list m-b-md" style="padding: 0">
                                <li><a href="mailbox.jsp?username=<%=username%>&password=<%=password%>" style="font-size: 17px; "> <i ></i>收件箱 </a></li>
                                <li><a href="mailbox.jsp"  style="font-size: 17px; "> <i></i>发件箱</a></li>
                                <li><a href="mailbox.jsp" style="font-size: 17px; "> <i ></i>星标邮箱</a></li>
                                <li><a href="mailbox.jsp" style="font-size: 17px; "> <i></i>草稿箱</a></li>
                                <li><a href="mailbox.jsp" style="font-size: 17px; "> <i></i>垃圾箱</a></li>
                           
                           <div class="space-25"></div>
							  <li><a  href="mail_send.jsp" style="font-size: 20px; font-family:jokerman"><i></i><strong>Write Letter</strong></a></li>
                          </ul>
                            <div class="clearfix"></div>
                            <div class="space-25"></div>
                             <img src="img/p4.jpg" width="270" height="230" alt=""/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-9 animated fadeInRight">
            <div class="mail-box-header">
                 <div class="pull-right tooltip-demo">
                    <a href="mail_send.jsp" class="btn btn-primary btn-sm" data-toggle="tooltip" data-placement="top" title="Reply"><i class="fa fa-reply"></i>回复</a>
                   
                    <a href="mailbox.html" class="btn btn-primary btn-sm" >删除 </a>
                </div>
                <h2>
                    查看邮件
                </h2>
                <div class="mail-tools tooltip-demo m-t-md">

					<%
					String from = "";
       				String subject = ""; 
       				String sendDate=""; 
       				Folder folder = (Folder) session.getAttribute("folder");
       				int msgnum=Integer.valueOf(request.getParameter("msgnum"));
       				Message message = folder.getMessage(msgnum);
       				
       				from = MimeUtility.decodeText(message.getFrom()[0].toString());
             		subject = message.getSubject();
             		sendDate = DateFormat.getInstance().format(message.getSentDate());
             		System.out.println("contentType：" + message.getContentType());
					%>
                    <h3>
                        <span class="font-noraml">subject: </span><%=subject %>
                    </h3>
                    <h5>
                        <span class="pull-right font-noraml"><%=sendDate %></span>
                        <span class="font-noraml">发件人: </span><%=from %>
                    </h5>
                    
                </div>
            </div>
            <div class="mail-box">
				<div class="mail-body">
                    <p>
                    <%
                    	String s="";
                    	DoReceive rec=null;
						rec=new DoReceive((MimeMessage)message);
						rec.getMailContent(message);
						s=rec.getMailbody();
					%>
					<%=s %>
                    </p>
                </div>
                <div class="mail-attachment">
                    <p>
                    <%
            		// 如果该邮件是组合型"multipart/*"则可能包含附件等
            		if (message.isMimeType("multipart/*")) {
                		Multipart mp = (Multipart) message.getContent();
						for (int i = 0; i < mp.getCount(); i++) {
                    		BodyPart bp = mp.getBodyPart(i);
							// 如果该BodyPart对象包含附件，则应该解析出来
                    		if (bp.getDisposition() != null) {
                        		String filename = bp.getFileName();
                        		System.out.println("filename：" + filename);
                        		if (filename.startsWith("=?")) {
                            		// 把文件名编码成符合RFC822规范
                            		filename = MimeUtility.decodeText(filename);
                        		}
                        		// 生成打开附件的超链接
                        		out.print("附件：");
                        		out.print("<a href=HandleAttach?msgnum=" + msgnum + "&&bodynum=" + i + "&&filename=" + filename
                                	+ ">" + filename + "</a><br/>");
                    		}
                		}
            		}
                    %>
                    </p>
				</div>
				 
                <div class="mail-body text-right tooltip-demo">
                	<!-- -->
                	<a class="btn btn-sm btn-primary" href="mail_send.jsp?msgnum=<%=msgnum%>">回复</a>
                	<a class="btn btn-sm btn-primary" href="mailbox.jsp?username=<%=username%>&password=<%=password%>">返回</a>
                	<a class="btn btn-sm btn-primary" href="#" data-toggle="modal" data-target="#delete">删除</a>
               </div>
               <div class="clearfix"></div>
            </div>
            </div>
        </div>
        </div>
        

        </div>
        </div>

    <!-- Mainly scripts -->
    <script src="js/jquery-2.1.1.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

    <!-- Custom and plugin javascript -->
    <script src="js/inspinia.js"></script>
    <script src="js/plugins/pace/pace.min.js"></script>

    <!-- iCheck -->
    <script src="js/plugins/iCheck/icheck.min.js"></script>
    <script>
        $(document).ready(function(){
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
    </script>
	
<div class="modal fade" id="delete" tabindex="-1" role="dialog"  >
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-body" >
         <p align="center" style="font-family:'微雅软黑'; font-size:24px;">确认删除？</p>
         <br/>
         <p align="center" style="font-family:'微雅软黑'; font-size:20px;" id="delid"></p>
        </div>
        <div class="modal-footer">        
        <form action="/Mail/DoDelete" method="get" >
         <input type="hidden" name="msgnum" value="<%=msgnum %>"  />
         <input type="hidden" name="username" value="<%=username %>"  />
         <input type="hidden" name="password" value="<%=password %>"  />
		 <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
		 <input type="submit" value="确认" class="btn btn-primary" >					
		</form>
        </div>
        
      </div>
    </div>
</div>	
</body>
<div  >
            
            <div style=" text-align:center">
                <strong></strong> our电子邮箱@软件1401班
            </div>
</div>


</html>
